<?php


if (!isset($_POST['pic_id'])) {
    header('Location: ../');
    exit();
}

require_once '../../includes/includes.php';

$id = $_POST['pic_id'];

$pics = getCleanPics();
$pics = indexOf('id', $pics);

$albums = getAlbums();
$albums = indexOf('id', $albums);

echo 'picId : ' . $id . ' album: ' . $albums[$pics[$id]['album_id']]['name'] . ' pics : ' . $pics[$id]['source'];

$table = 'photographs';
$where_sql = 'id = :id';
$where_data = array('id' => $id);

$db->delete($table, $where_sql, $where_data);
unlink('../../albums/' . $albums[$pics[$id]['album_id']]['name'] . '/' . $pics[$id]['source']);

